% scale aux_data frames to video data frames

aaa=1:length(aux_data(1,:));

scale=length(aaa)/size(data,3);
tmp=1:size(data,3);

for ind = 1:length(tmp)
    bbb(ind)=round(ind*scale-scale+1);
end

for mnd = 1:size(aux_data,1)
    for knd = 1:length(bbb)
        aux_ind(mnd,knd)=aux_data(mnd,bbb(knd));
    end
end

% frame by frame video data

scal=size(data2,3)/size(data,3);
tm=1:size(data,3);

for xnd = 1:length(tm)
    bbbb(xnd)=round(xnd*scal-scal+1);
end

for znd = 1:length(bbbb)
    data2_sc(:,:,znd)=data2(:,:,bbbb(znd));
end


% calculate mean and subtract
    
mean_data(:,:,1)=mean(data,3);
mean_data=int16(mean_data);
for knd = 1:size(data,3)
    data_(:,:,knd)=data(:,:,knd)-mean_data(:,:);
end
